<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>改变表格的cellpadding和cellspacing</title>
</head>

<body>
    <table id="myTable" border="1">
        <tr>
            <td>100</td>
            <td>200</td>
        </tr>
        <tr>
            <td>300</td>
            <td>400</td>
        </tr>
    </table>
    <br>
    <input type="button" onclick="padding()" value="修改单元格边距">
    <input type="button" onclick="spacing()" value="修改单元格间距">
    <script>
        function padding() {
            document.getElementById('myTable').cellPadding = "15";
        }
        function spacing() {
            document.getElementById('myTable').cellSpacing = "15";
        }
    </script>
</body>

</html>